package com.lame.sbconstant.command;

import org.apache.commons.lang3.StringUtils;

import java.io.File;

public class KoalExtractEntityCommand implements Command {

    private Command command = new TardisExtractMain();

    @Override
    public void execute(Context ctx, String f) throws Exception {
        File file = new File(f);
        final String name = file.getParentFile().getName();
        if (StringUtils.equalsIgnoreCase(name, "entity")) {
            ctx.baseDir(file.getParentFile().getParentFile().getAbsolutePath());
            System.out.println("BASE_DIR:\t" + ctx.baseDir());
            command.execute(ctx, f);
        } else {
            //ignore
        }
    }

    public static void main(String[] args) {
        Context ctx = new Context();
        ctx.aiDetect = true;
        ctx.saveFile = false;
        KoalExtractEntityCommand cmd = new KoalExtractEntityCommand();
        try {
            cmd.execute(ctx, "/media/lame/0DD80F300DD80F30/koal/kcsp-admin/kcsp-boot/kcsp-boot-module-system/src/main/java/kl/kcsp/modules/applyorder/entity/ServiceArea.java");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
